package com.ctshk.sapp.train.controller;


import com.ctshk.common.annotations.Authority;
import com.ctshk.common.dto.Result;
import com.ctshk.common.model.TokenUser;
import com.ctshk.rpc.train.dto.TrainTicketsInitializationSettingsDTO;
import com.ctshk.rpc.train.req.TrainTicketsInitializationSettingsReq;
import com.ctshk.rpc.train.service.ITrainTicketsInitializationSettingsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 火车票api初始化设置表 前端控制器
 * </p>
 *
 * @author 彭柳霖
 * @since 2021-03-10
 */
@Api(value="资源中心-火车API初始化设置", tags="资源中心-火车API初始化设置")
@RestController
@RequestMapping("/train-tickets-initialization-settings")
public class TrainTicketsInitializationSettingsController extends BaseController {

    @DubboReference
    private ITrainTicketsInitializationSettingsService initializationSettingsService;

    @ApiOperation(value = "火车票api初始化设置", notes = "火车票api初始化设置")
    @PostMapping(value = "/save")
    public Result saveSettingInfo(@RequestBody @Valid TrainTicketsInitializationSettingsReq initializationSettingsReq) {
        TokenUser user = getCurrentUser(getRequest());
        return initializationSettingsService.saveSettingInfo(initializationSettingsReq,user);
    }

    @ApiOperation(value = "查询火车票初始化默认API详情", notes = "查询火车票初始化默认API详情")
    @GetMapping(value = "/detail")
    @Authority
    public Result<TrainTicketsInitializationSettingsDTO> queryDetail(@RequestParam(value = "supplierId", required = true) Long supplierId) {
        return Result.success(initializationSettingsService.queryDetail(supplierId));
    }
}
